<%@ include file="/WEB-INF/views/taglib.jsp" %>
<div class="centerWrapper">

<div id="reportStatus" class="notice">
    <h2>Please wait</h2>
    <p>
      Please wait while processing your report ... <img src="${imageUrl}/loadingAnimation.gif">
    </p>
</div>

<spring:url value="/report/download/${report.reportId}" var="reportUrl"></spring:url>
<div id="reportSuccessResult" style="display:none" class="info">
<h2>Success</h2>
<p>Your Report download will start shortly ... <br> Problems with the download? Please use <a href="${reportUrl}">this</a> direct link, or re-create report
</p>
</div>

<div id="reportErrorResult" style="display:none" class="error">
<h2>Error</h2>
<p>
There is problem when generating report. Please contact your administrator.
</p> 
</div>

<div id="reportNoRecordFound" style="display:none" class="info">
<h2></h2>
<p>
There are no records available for the input filters selected.
</p> 
</div>
</div>
	<script type="text/javascript">
	
		var reportInterval;
		$(document).ready(function() {
			reportInterval = setInterval(getReportStatus,5000);
		});
		
		function getReportStatus()
		{
			$.get('<spring:url value="/ajax/showReportProcessingStatus/${report.reportId}"></spring:url>',function(data){
				if(data=='SUCCESS')
				{
					clearInterval(reportInterval);
					$('#reportStatus').hide();
					$('#reportSuccessResult').show()
					location.href="${reportUrl}";
				}
				else if(data=='FAIL')
				{
					clearInterval(reportInterval);
					$('#reportStatus').hide();
					$('#reportErrorResult').show();
				}
				
				else if(data=='NORECORD')
				{
					clearInterval(reportInterval);
					$('#reportStatus').hide();
					$('#reportNoRecordFound').show();
				}
			});
		}
	</script>
	